package org.example.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 *
 */
@Component
public class MyListener implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {

        System.out.println("执行监听器");
        System.out.println("取得mysql数据，保存到redis里面");

        /*
            这个context叫做应用上下文
            通过应用上下文取得bean，完成所需业务流程
         */
        /*ApplicationContext context = contextRefreshedEvent.getApplicationContext();
        Xxxx  xxx = context.getBean("xxx");*/
    }
}
